package madixin.t1;

import java.util.HashMap;
import java.util.Map;

class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> index = new HashMap<Integer, Integer>();
        for (int i = 0; i < nums.length; i++) {
            if (index.containsKey(target - nums[i])) {
                return new int[]{index.get(target - nums[i]), i};
            }
            index.put(nums[i], i);
        }
        return null;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        s.twoSum(new int[]{3, 2, 4}, 6);
    }
}